//
//  VpnConnector.h
//  VPNDemo
//
//  Created by Gin on 2017/1/3.
//  Copyright © 2017年 Gin. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <NetworkExtension/NetworkExtension.h>



#import "VpnInfo.h"

typedef NS_ENUM(NSInteger, VPNStatus) {
    VPNStatusInvalid,
    VPNStatusDisconnected,
    VPNStatusConnecting,
    VPNStatusConnected,
    VPNStatusDisconnecting,
};

typedef NS_ENUM(NSUInteger, VpnConnectorError) {
    VpnConnectorErrorNone,
    VpnConnectorErrorLoadPrefrence,
    VpnConnectorErrorSavePrefrence,
    VpnConnectorErrorRemovePrefrence,
    VpnConnectorErrorStartVPNConnect
};

@protocol VpnConnectorDelegate <NSObject>


- (void)vpnConnectionDidRecieveError:(VpnConnectorError)error;

- (void)vpnStatusDidChange:(VPNStatus)status;

@end


@interface VpnConnector : NSObject

#pragma mark - Common


@property (nonatomic, weak) id<VpnConnectorDelegate> delegate;


+ (instancetype)vpnConnector;




- (void)checkVPNPreferenceSuccess:(void (^)(BOOL isInstalled))successBlock;
- (void)createVPNPreferenceWithData:(id)data success:(void (^)())successBlock;                          
- (void)removeVPNPreferenceSuccess:(void (^)())successBlock;
- (void)modifyVPNPreferenceWithData:(id)data success:(void (^)())successBlock;

- (void) loadProviderManage:(void(^)(VPNStatus vpnStatus)) complete;



- (void)startVPNConnectSuccess:(void (^)())successBlock;
- (void)stopVPNConnectSuccess:(void (^)())successBlock;




- (VpnInfo *)getCurrentVPNInfo;
- (VPNStatus)getCurrentStatus;                            

@end
